#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time: 2022/9/16 19:09
# @Author: 张涛
# @Email: xxx@gmail.com
# @File：chanpin_opt_page.py

"""
产品页面
"""


from selenium.webdriver.support.select import Select  #引入Select
from selenium.webdriver.common.by import By
from pages.base_page import BasePage

class Product(BasePage):
    qbsck_locator = (By.ID,'check_all') #定位全部删除框
    scan_locator = (By.CSS_SELECTOR,'#delete') #定位删除按钮
    xlk_a_locator = (By.ID,'field') #定位下拉框1
    xlk_b_locator = (By.ID,'condition') #定位下拉框2
    sssrk_locator = (By.ID,'search')  #搜索输入框
    ssan_locator = (By.CSS_SELECTOR,'#dosearch') #定位搜索按钮
    cpmc_locatoy = (By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(1) > td:nth-child(3) > a > span') #定位产品名称1
    bzxx_locator = (By.XPATH,'/html/body/div[5]/div[2]/div[2]/div[1]/ul/li[2]/form/ul/li[5]/a') #定位帮助按钮
    dwcjr_locator = (By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(1) > td:nth-child(5) > a') #定位创建人
    dwxxnr_locator = (By.CSS_SELECTOR,'#content') #定位发送内容
    dwfsan_locator = (By.CSS_SELECTOR,'#send')  #定位发送按钮
    dwymxs_locator = (By.CSS_SELECTOR,'#message_item') #定位消息提示


    cjcp_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div:nth-child(2) > div.pull-right > a') #定位添加产品
    cpgj_locator = (By.CSS_SELECTOR,'body > div.container > div.row > div:nth-child(2) > div.pull-right > div > button') #产品工具
    drcp_locator = (By.CSS_SELECTOR,'#import_excel') #导入产品
    drwj_locator = (By.CSS_SELECTOR,'#attachment1 > input[type=file]') #导入文件

    qddr_locator = (By.XPATH,'/html/body/div[8]/div[2]/form/table/tbody/tr[4]/td[2]/input[1]') #确定导入按钮

    dccp_locator = (By.ID,'excelExport') #导出产品
    dwck_locator = (By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(1) > td:nth-child(6) > a:nth-child(1)') #定位查看
    dwbj_locator = (By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(1) > td:nth-child(6) > a:nth-child(2)') #定位编辑

    xiangying_locator = (By.XPATH,'/html/body/div[5]/div[2]') #响应提示内容

    tpneir_locator = (By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(1) > td:nth-child(2) > img') #定位图片位置
    dwcpm_locator = (By.CSS_SELECTOR,'#form1 > table > tbody > tr:nth-child(1) > td:nth-child(3) > a > span')  #定位产品名
    dwcpsc_locator = (By.XPATH,'/html/body/div[5]/div[2]')  #定位删除提示

    def qbsck_element(self):
        '''勾选删除'''
        self.driver.find_element(*self.qbsck_locator).click()

    def scan_element(self):
        '''点击删除'''
        self.driver.find_element(*self.scan_locator).click()
        self.driver.switch_to.alert.accept()  # 提示框选择确定

    def xlk_a_element(self,xlk_q):
        '''搜索下拉框1选择'''
        xlk_a = self.driver.find_element(*self.xlk_a_locator)
        Select(xlk_a).select_by_visible_text(xlk_q)

    def xlk_b_element(self, xlk_w):
        '''搜索下拉框2选择'''
        xlk_b = self.driver.find_element(*self.xlk_b_locator)
        Select(xlk_b).select_by_visible_text(xlk_w)

    def sssrk_element(self,sssrk_a):
        '''输入搜索输入框'''
        self.driver.find_element(*self.sssrk_locator).send_keys(sssrk_a)

    def ssan_element(self):
        '''点击搜索按钮'''
        self.driver.find_element(*self.ssan_locator).click()

    def cpmc_element(self):
        '''获取产品名'''
        cpmc_a = self.driver.find_element(*self.cpmc_locatoy).text
        return cpmc_a



    def dwcjr_element(self):
        '''点击创建人'''
        self.driver.find_element(*self.dwcjr_locator).click()

    def cjcp_element(self):
        '''点击添加产品'''
        self.driver.find_element(*self.cjcp_locator).click()



    def cpgj_element(self):
        '''点击产品工具'''
        self.driver.find_element(*self.cpgj_locator).click()

    def drcp_elemnt(self):
        '''点击导入产品'''
        self.driver.find_element(*self.drcp_locator).click()

    def drwj_element(self,wenjian):
        '''导入文件'''
        self.driver.find_element(*self.drwj_locator).send_keys(wenjian)

    def qddr_element(self):
        '''点击确定导入按钮'''
        self.driver.find_element(*self.qddr_locator).click()


    def bzxx_element(self):
        '''帮助按钮'''
        self.driver.find_element(*self.bzxx_locator).click()


    def dccp_element(self):
        '''点击导出产品'''
        self.driver.find_element(*self.dccp_locator).click()

    def dwck_element(self):
        '''点击查看'''
        self.driver.find_element(*self.dwck_locator).click()

    def dwbj_element(self):
        '''点击编辑'''
        self.driver.find_element(*self.dwbj_locator).click()

    def xiangying_element(self):
        '''获取响应内容'''
        xiangying =  self.driver.find_element(*self.xiangying_locator).text
        return xiangying

    def tpneir_element(self):
        tpneir_a = self.driver.find_element(*self.tpneir_locator).text
        return tpneir_a

    def dwcpm_element(self):
        '''定位产品名'''
        dwcpm_a = self.driver.find_element(*self.dwcpm_locator).text
        return dwcpm_a

    def dwcpsc_element(self):
        '''定位删除提示'''
        dwcpsc_a = self.driver.find_element(*self.dwcpsc_locator).text
        return dwcpsc_a

    def dwxxnr_element(self,dwxxnr_a):
        '''发送站内信内容'''
        self.driver.find_element(*self.dwxxnr_locator).send_keys(dwxxnr_a)

    def dwfsan_element(self):
        '''点击发送按钮'''
        self.driver.find_element(*self.dwfsan_locator).click()

    def dwymxs_element(self):
        dwymxs = self.driver.find_element(*self.dwymxs_locator).text
        return dwymxs
